{% extends 'layouts/base.html' %}
{% block content %}
<div class="row">
    <div class="col-xs-12">
        <!-- PAGE CONTENT BEGINS -->
        <form action="{{ url('backend/foreman/edit', {fm_id:foreman.fm_id}) }}" class="form-horizontal" role="form" method="post" enctype="multipart/form-data">

            <div class="form-group{% if errors['fm_name'] is not empty %} has-error{%endif%}">
                <label for="fm_name" class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right">领班名称<span class="red">*</span></label>
                <div class="col-xs-12 col-sm-4">
                    <span class="block input-icon input-icon-right">
                        <input type="text" id="fm_name" placeholder="领班名称" name="fm_name" class="col-xs-12" value="{{foreman.fm_name}}" />
                    </span>
                </div>
                <div class="help-block col-xs-12 col-sm-reset inline"> {% if errors['fm_name'] is not empty %}{{errors['fm_name']}}{% else %} {%endif%} </div>
            </div>

            <div class="form-group{% if errors['photo'] is not empty %} has-error{%endif%}">
                <label for="photo" class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right">照片<span class="red">*</span></label>
                <div class="col-xs-12 col-sm-4">
                    <span class="block input-icon input-icon-right">
                        <input multiple="" type="file" id="photo" placeholder="照片" name="photo" class="col-xs-12" value="{{foreman.photo}}" />
                    </span>
                </div>
                <div class="help-block col-xs-12 col-sm-reset inline"> {% if errors['photo'] is not empty %}{{errors['photo']}}{% else %} {%endif%} </div>
            </div>

            <div class="form-group{% if errors['phone'] is not empty %} has-error{%endif%}">
                <label for="phone" class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right">电话<span class="red">*</span></label>
                <div class="col-xs-12 col-sm-4">
                    <span class="block input-icon input-icon-right">
                        <input type="text" id="phone" placeholder="电话" name="phone" class="col-xs-12" value="{{foreman.phone}}" />
                    </span>
                </div>
                <div class="help-block col-xs-12 col-sm-reset inline"> {% if errors['phone'] is not empty %}{{errors['phone']}}{% else %} {%endif%} </div>
            </div>

            <div class="form-group{% if errors['certificate'] is not empty %} has-error{%endif%}">
                <label for="certificate" class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right">身份证<span class="red">*</span></label>
                <div class="col-xs-12 col-sm-4">
                    <span class="block input-icon input-icon-right">
                        <input type="text" id="certificate" placeholder="身份证" name="certificate" class="col-xs-12" value="{{foreman.certificate}}" />
                    </span>
                </div>
                <div class="help-block col-xs-12 col-sm-reset inline"> {% if errors['certificate'] is not empty %}{{errors['certificate']}}{% else %} {%endif%} </div>
            </div>

            <div class="form-group{% if errors['remark'] is not empty %} has-error{%endif%}">
                <label for="remark" class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right">备注<span class="red">*</span></label>
                <div class="col-xs-12 col-sm-4">
                    <span class="block input-icon input-icon-right">
                        <textarea id="remark" placeholder="备注" name="remark" class="col-xs-12" >{{foreman.remark}}</textarea>
                    </span>
                </div>
                <div class="help-block col-xs-12 col-sm-reset inline"> {% if errors['remark'] is not empty %}{{errors['remark']}}{% else %} {%endif%} </div>
            </div>

            <div class="clearfix form-actions">
                <div class="col-md-offset-3 col-md-9">
                    <button class="btn btn-info" type="submit">
                        <i class="ace-icon fa fa-check bigger-110"></i>
                        提交
                    </button>

                    &nbsp; &nbsp; &nbsp;
                    <a class="btn" href="javascript:;" onclick="history.back(); ">
                        <i class="ace-icon fa fa-undo bigger-110"></i>
                        后退
                    </a>
                </div>
            </div>

        </form>
    </div><!-- /.col -->
</div><!-- /.row -->
{% endblock %}
{% block script %}
<style>
.ace-file-multiple .ace-file-container .ace-file-name .ace-icon{
    width:100%;
    height:100px;
    position: center
}
.fa-img {
    background-image: url("{{foreman.photo}}");
    background-size:100% 100%;
    background-repeat:no-repeat;
}
</style>

<script type="text/javascript">
    $(document).ready(function(){

        $(".ace-switch").each(function () {
            var aceswitch = this;

            aceswitch.addEventListener("click", function(){
                id = this.id.replace("_radio", "");
                if(this.checked){
                    $("#"+id).val('1');
                } else {
                    $("#"+id).val('0');
                }
                });
        });
        $('#photo').ace_file_input({
           style:'well',
           btn_choose:'点击这里修改图片',
           btn_change:null,
           no_icon:'ace-icon fa {% if foreman.photo %}fa-img{% else %}fa-cloud-upload{% endif %}',
           droppable:false,
           thumbnail:'large'//large | fit
        });
        $('#addtime').datetimepicker({format: 'YYYY-MM-DD hh:mm:ss'}).next().on(ace.click_event, function(){
            $(this).prev().focus();
        });
    });

    

</script>
{% endblock %}
